package jdk8;

public class SynchronizTest {

    public static void main(String[] args) {
        SynchronizTest test = new SynchronizTest();
        new Thread(test::testObjectSync).start();
        new Thread(test::testObjectSync).start();
    }

    String lock = "lock";

    public void testMethodSync() {
        System.out.println(" method synchronized ");
    }

    public void testObjectSync() {
        synchronized (lock) {
            System.out.println(" method synchronized ");
        }
    }
}
